/**<
10. Print a 9 integer array to the screen using a loop.  Ask the user for a
number between 1 and 9. If the user does not enter a number between 1 and 9,
 repeatedly ask for a number until they do. Once they have entered a number
 between 1 and 9, print the array. Then search the array for the number that
 the user entered and print the index of that element.

 */

 #include<iostream>
 #include<cstdlib>
 #include<ctime>
 using namespace std;

 void GuessNumber(){

    #define ARRAY_SIZE 9
    int nArray[ARRAY_SIZE];
    srand(time(0));
    //create random numbers (up to 20) for all ints in the array
    for(int i=0;i<ARRAY_SIZE;i++){
        nArray[i] = rand() % 20;
    }

    //int nArray[9] = {2,3,4,6,7,20,15,40,345};
    cout << "Here are your #s: ";
    for(int i = 0;i<ARRAY_SIZE;i++){
        cout << nArray[i] << " ";
    }

    int nUserNum = 0;
    while (nUserNum > 9 || nUserNum < 1){
        cout << endl << "Please enter a number: ";
        cin >> nUserNum;
    }

    cout << "You picked index: " << nUserNum << endl;
    cout << "The number from the list is: " << nArray[nUserNum -1] << endl;



 }
